//ex10_10_8.cpp
//C:10.11:stack.cpp -- Stack member functions
#include <iostream>
#include "list.h"
List::List()    // Create an empty stack
{
    top = 0;
}

bool List::isempty() const
{
    return top == 0;
}

bool List::isfull() const
{
    return top == MAX;
}

bool List::add(Item & item)
{
    if(top < MAX)
    {
        items[top++] = item;
        return true;
    }
    else 
    {
        return false;
    }
}
/*
bool List::pop(Item & item)
{
    if(top > 0)
    {
        item = items[--top];
        return true;
    }
    else 
    {
        return false;
    }
}
*/

void List::visit(void(*pf)(Item &))
{
    for(int i = 0; i < top; i++)
    {
        pf(items[i]);
    }
}

void visit_item(Item &item)
{
    std::cout << "Item = " << item << '\n';
}